{include file="public/header"/}
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcf_help.css?v={$version}"/>
<script src="{__PUBLIC_PATH}/common/js/jquery.min.js?v={$version}"></script>
<script src="{__PUBLIC_PATH}/admin/pcf/global.js?v={$version}"></script>
</head>
<body>
<link rel="stylesheet" type="text/css" href="{__PUBLIC_PATH}/common/plugins/codemirror/codemirror.css?v={$version}">
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/codemirror.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/xml/xml.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/javascript/javascript.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/css/css.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/php/php.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/clike/clike.js?v={$version}"></script>
<script type="text/javascript" src="{__PUBLIC_PATH}/common/plugins/codemirror/mode/htmlmixed/htmlmixed.js?v={$version}"></script>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body">
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                  <label class="layui-form-label"><b>*</b>文件路径</label>
                  <div class="layui-input-inline">
                   <input type="text" name="activepath" value="{$info['activepath']|default=''}" lay-verify="required" class="layui-input">
                  </div>
                  <div class="layui-input-inline layui-btn-container " style="width:auto;">
                    <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                    <div class="layui-form-inline2 ey_helptips_txt">空白表示根目录，不允许用 “..” 形式的路径</div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label"><b>*</b>文件名称</label>
                  <div class="layui-input-inline">
                   <input type="text" name="filename" value="{$info['filename']|default=''}" lay-verify="required" class="layui-input">
                  </div>
                  <div class="layui-input-inline layui-btn-container " style="width: auto;">
                    <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                    <div class="layui-form-inline2 ey_helptips_txt">不允许用 “..” 形式的路径</div>
                  </div>
                </div>
                <div class="layui-form-item">
                   <label class="layui-form-label">文件源码</label>
                   <div class="layui-form-inline2">
                      <textarea id="content" lay-ignore style='width:99%;height:450px;background:#ffffff;'>{$info.content|raw}</textarea>
                   </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block">
                      <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                  </div>
                </div>
            </div>
          </div>
        </div>
    </div>
</div>
</div>
{include file="public/footer"/}
<script>
  layui.use(['layer', 'form'], function () {
    var $ = layui.$,
    layer = layui.layer,
    form = layui.form;
    var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
        lineNumbers: true, // 显示行号
        lineWrapping: true, // 在行槽中添加行号显示器、折叠器、语法检测器`
        autofocus:true,  //自动聚焦
        mode: '{$info.extension}'
    });
    //监听提交
    form.on('submit(formSubmit)', function(data){
        layer.load(2);
        data.field.content = editor.getValue();
        $.ajax({
            type : 'post',
            url : "{:url('/channel.Filemanager/edit')}",
            data : data.field,
            dataType : 'json',
            success : function(res){
                layer.closeAll('loading');
                if(res.status){
                    layer.msg(res.msg,{icon:1,time:1000},function(){
                        parent.location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{icon:2,time:1000});
                }
            },
            error: function(e){
                layer.closeAll('loading');
                layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
            }
        });
        return false;
    });
  });
</script>
</body>
</html>